const api = require('../../config/workSheet.js')
Page({
	/**
   * 页面的初始数据
   */
	data: {
    lists:[],
    id:'',
    userId:''
  },
  getList() {
    wx.request({
      url: api.list,
      data: {
        id:this.data.id,
        userId:this.data.userId
      },
      method:'GET',
      success: (res) => {
        if(res.data.code === 100) {
          let element = {...{},...res.data.object}
          for (const key in element) {
            if( element.establish ==1) {
              element.establish='是'
            }else {
              element.establish='否'
            }
            if( element.storageStandard ==1) {
              element.storageStandard='是'
            }else {
              element.storageStandard='否'
            }
            if( element.evaluationSystem ==1) {
              element.evaluationSystem='是'
            }else {
              element.evaluationSystem='否'
            }
            if( element.routineMaintenance ==1) {
              element.routineMaintenance='是'
            }else {
              element.routineMaintenance='否'
            }
            if( element.blacklist ==1) {
              element.blacklist='是'
            }else {
              element.blacklist='否'
            }
            if( element.quality ==1) {
              element.quality='是'
            }else {
              element.quality='否'
            }
            if( element.speed ==1) {
              element.speed='是'
            }else {
              element.speed='否'
            }
            if( element.securitys ==1) {
              element.securitys='是'
            }else {
              element.securitys='否'
            }
            if( element.businessAffairs ==1) {
              element.businessAffairs='是'
            }else {
              element.businessAffairs='否'
            }
            if( element.awardWinning ==1) {
              element.awardWinning='是'
            }else {
              element.awardWinning='否'
            }
            if(element.customer == 1) {
              element.customer='电话客服'
            }else {
              element.customer='微信客服'
            }
          }
          this.setData({
            lists:element
          })
        }else {
          wx.showToast({
            title: res.data.msg,
            duration: 2000
          });
        }
      }
    });
  },

	/**
   * 生命周期函数--监听页面加载
   */
	onLoad: function(options) {
    const {id} = options
    const userId = wx.getStorageSync('wxUser')?wx.getStorageSync('wxUser').id:''

    this.setData({
      id,
      userId
    })
    this.getList()
	},

	/**
   * 生命周期函数--监听页面初次渲染完成
   */
	onReady: function() {},

	/**
   * 生命周期函数--监听页面显示
   */
	onShow: function() {},

	/**
   * 生命周期函数--监听页面隐藏
   */
	onHide: function() {},

	/**
   * 生命周期函数--监听页面卸载
   */
	onUnload: function() {},

	/**
   * 页面相关事件处理函数--监听用户下拉动作
   */
	onPullDownRefresh: function() {},

	/**
   * 页面上拉触底事件的处理函数
   */
	onReachBottom: function() {},

	/**
   * 用户点击右上角分享
   */
	onShareAppMessage: function() {}
})
